#pragma once
#include <QApplication>
#include <QThread>
#include "keyboard.h"
#define TX 0
#define TY 1
#define TZ 2
#define DX 3
#define DY 4
#define DZ 5
#define AN 0x31
#define AUS 0x30

enum pstate
{
  STANDBY,
  PLOTTING,
  PAUSE,
  ERROR,
  CANCELED,
  MANU
};

class CStepper : public QThread
{
public:
  CStepper();
  ~CStepper();
  pstate state;
  int     speed;
  double  dstep;
  int     mx,my,mz;
  int     zf, zp;
  bool    pdir;
  QList<int> keys;
  QList<int> ckeys;

  void run();
//  void go();
  void exec();
  void reset();
  void line(int x, int y, int z);

  bool free();
  void step(int ia);
  void set(int p, int v);
  void load();
  void deload();
  void pause();
  void reades();

  int x,y,z;
  int c[3];
  int cd[3];

private:
  int  MyDriver;
  char es[3];
};

extern CStepper s;
